package de.hszg.wjl.datacore.model;

import static org.junit.Assert.*;

import org.junit.Test;

public class SingleChoiceQuestionTest extends QuestionTest<SingleChoiceQuestion>  {

	@Test
	public void testGetAwnser() {
		SingleChoiceQuestion question = new SingleChoiceQuestion();
		question.setAnswer("1");
		assertTrue(question.getAnswer().equals("1"));
		question.setAnswer("3");
		assertTrue(question.getAnswer().equals("3"));
	}

	
	@Test
	public void testXMLParsing() {
		SingleChoiceQuestion question = createQuestion();
		assertTrue(question.getType() == QuestionType.CHOICE);
		assertTrue(question.getID().equals("3"));
		assertTrue(!question.isRequired());
		assertTrue(question.getText().equals(
				"What programming language do you prefer?"));

		assertTrue(question.getOptions().get("1").equals("C++"));
		assertTrue(question.getOptions().get("2").equals("Scala"));
		assertTrue(question.getOptions().get("3").equals("Java"));

	}

	@Override
	protected String getQuestionXML() {
		return "<question type='choice' required='false' id='3'><text>What programming language do you prefer?</text><choices><choice id='1'>C++</choice><choice id='2'>Scala</choice><choice id='3'>Java</choice></choices></question>";
	}
}
